package com.lagou.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * @ClassName: OrderStatusEnum
 * @Description:
 * @Author: qjc
 * @Date: 2021/12/21 3:59 下午
 */
@Getter
@AllArgsConstructor
public enum OrderStatusEnum {

    WAIT_PAY(0, "待支付"),
    PAID(1, "已支付"),
    CANCEL(2, "已取消"),
    ;

    private Integer code;

    private String value;

    public static Optional<OrderStatusEnum> getByCode(Integer code) {
        return Arrays.stream(OrderStatusEnum.values()).parallel()
                .filter(data -> data.getCode().equals(code)).findFirst();
    }

}
